package cn.edu.sicau.databasepp.entity;

import javax.persistence.*;
import java.util.Objects;

@Entity
@Table(name = "user_is_role", schema = "sqlexcise", catalog = "")
public class UserIsRoleEntity
{
    private long userId;
    private UserEntity userByUserId;

    @Id
    @Column(name = "user_id", nullable = false)
    public long getUserId()
    {
        return userId;
    }

    public void setUserId(long userId)
    {
        this.userId = userId;
    }

    @Override
    public boolean equals(Object o)
    {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        UserIsRoleEntity that = (UserIsRoleEntity) o;
        return userId == that.userId;
    }

    @Override
    public int hashCode()
    {
        return Objects.hash(userId);
    }

    @OneToOne
    @JoinColumn(name = "user_id", referencedColumnName = "user_id", nullable = false)
    public UserEntity getUserByUserId()
    {
        return userByUserId;
    }

    public void setUserByUserId(UserEntity userByUserId)
    {
        this.userByUserId = userByUserId;
    }
}
